﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace MDIApplication
{
    public partial class RoomOccupancyReport : Form
    {
        public RoomOccupancyReport()
        {
            InitializeComponent();
        }

        private void RoomOccupancyReport_Load(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the 'RmOccuDataSet.RoomOccupancy1' table. You can move, or remove it, as needed.
            
            // TODO: This line of code loads data into the 'RmOccuDataSet.RoomOccupancy' table. You can move, or remove it, as needed.
            this.RoomOccupancyTableAdapter.Fill(this.RmOccuDataSet.RoomOccupancy);
            this.reportViewer1.RefreshReport();
            this.RoomOccupancy1TableAdapter.Fill(this.RmOccuDataSet.RoomOccupancy1);
            this.reportViewer2.RefreshReport();
            this.reportViewer3.RefreshReport();
            dateTimePicker1.Value = DateTime.Today;
            dateTimePicker2.Value = DateTime.Today;
        }

        private void btnsearch_Click(object sender, EventArgs e)
        {
            lbldate.Text = dateTimePicker1.Value.ToShortDateString() + " To " + dateTimePicker2.Value.ToShortDateString();
            this.RoomOccupancyTableAdapter.FillByDate(this.RmOccuDataSet.RoomOccupancy, Convert.ToString(dateTimePicker1.Text), Convert.ToString(dateTimePicker2.Text));
            this.reportViewer1.RefreshReport();
           
            if (dateTimePicker1.Value > dateTimePicker2.Value)
            {
                MessageBox.Show("Incorrect (From) Date", "Error Message");
            }
        }

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            this.RoomOccupancy1TableAdapter.FillByMonth(this.RmOccuDataSet.RoomOccupancy1, Convert.ToDecimal(comboBox1.Text));
            this.reportViewer2.RefreshReport();
        }

        private void comboBox2_SelectedIndexChanged(object sender, EventArgs e)
        {
            this.RoomOccupancy1TableAdapter.FillByYear(this.RmOccuDataSet.RoomOccupancy1, Convert.ToDecimal(comboBox2.Text));
            this.reportViewer3.RefreshReport();
        }

        private void btnviewall_Click(object sender, EventArgs e)
        {
            this.RoomOccupancyTableAdapter.Fill(this.RmOccuDataSet.RoomOccupancy);
            this.reportViewer1.RefreshReport();
        }

        private void btnviewall2_Click(object sender, EventArgs e)
        {
            this.RoomOccupancy1TableAdapter.Fill(this.RmOccuDataSet.RoomOccupancy1);
            this.reportViewer2.RefreshReport();
        }

        private void btnviewall3_Click(object sender, EventArgs e)
        {
            this.RoomOccupancy1TableAdapter.Fill(this.RmOccuDataSet.RoomOccupancy1);
            this.reportViewer3.RefreshReport();
        }
    }
}
